﻿using System.Collections.Generic;
using System.Data;
using Amoo.Code.Common;


namespace Amoo.Code.Data
{
    public class Administrador:BaseData
    {
        public List<Entity.Administrador> GetAll()
        {
            IDataReader dr = ExecuteReader("SELECT idAdministrador, dsUsuario, dsSenha FROM administrador");
            List<Entity.Administrador> returnVal = new List<Entity.Administrador>();
            if (dr != null)
            {
                while(dr.Read())
                {
                    returnVal.Add(Entity.Administrador.Load(dr));
                }
            }
            return returnVal;
        }
        public Entity.Administrador GetAdminByUserAndPws(string usuario, string senha)
        {
            IDataReader dr = ExecuteReader(string.Format("SELECT idAdministrador, dsUsuario, dsSenha FROM administrador where dsUsuario='{0}' and dsSenha='{1}'", usuario, senha));
            if (dr != null)
            {
                if (dr.Read())
                {
                    return Entity.Administrador.Load(dr);
                }
                else
                    return null;
            }
            else
                return null;
            
        }
    }
}
